<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lesson 15</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
  <div id="root"></div>
</body>
<script>
// 父组件调用子组件的标签 通过标签上的属性向子组件动态的传值，子组件通过props接受值 
// 因为接受的值是string  静态传参都是string类型的 而动态的是number类型的 

const app1 =Vue.createApp(
  {
    data(){
      return {num:123}
    },
    template:`<div><test v-bind:content="num"></div>`
  }
)
app1.component('test',{
  props:['content'],
  template:`<div> {{typeof content}} </div>`
})



  const app = Vue.createApp({
    data() {
      return { num: 1234 }
    },
    template: `
      <div><test :content="num" /></div>
    `
  });

  // 对父组件动态传递的参数进行校验
  // type:String, Boolean, Array, Object, Function, Symbol
  // required 该参数必填
  // default 默认值
  app.component('test', {
    props: {
      content: {
        type: Number,
        // require:ture,
        validator: function(value) {
          return value < 1000;
        },
        // props:['content']告诉props接受content值   props:{content: string} 校验值是string类型 
        default: function() {
          return 456;
        }
      }
    },
    template: `<div>{{content}}</div>`
  });

  const vm = app.mount('#root');
</script>
</html>
